package com.tensquare.recruit.rest;

import com.tensquare.entity.Recruit;
import com.tensquare.entity.Result;
import com.tensquare.entity.StatusCode;
import com.tensquare.recruit.service.RecruitService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 招聘信息
 */

@RestController
@RequestMapping("recruit")
@CrossOrigin
public class RecruitRest {

    @Autowired
    RecruitService recruitService;

    /**
     * http://localhost:9002/recruit/search/recommend/1
     * @param state
     * @return
     */
    @RequestMapping(value = "/search/recommend/{state}", method = RequestMethod.GET)
    public Result recommend(@PathVariable("state") int state){

        return new Result(true, StatusCode.OK, "查询成功", recruitService.findTop4ByStateOrderByCreatetimeDesc(state) );
    }

    /**
     * 最新职位列表
     * http://localhost:9002/recruit/search/newlist/0
     * @param state
     * @return
     */
    @RequestMapping(value = "/search/newlist/{state}", method = RequestMethod.GET)
    public Result newlist(@PathVariable("state") int state){

        return new Result(true, StatusCode.OK, "查询成功", recruitService.newlist(state));
    }
}
